home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: Jeff Grossman <grossman@teleport.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Default Constructors
- Date: 13 Apr 1996 21:09:28 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4kp568$3ph@nadine.teleport.com>
- References: <316F2B88.5FC4@psych.stanford.edu>
- NNTP-Posting-Host: ip-pdx10-19.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
-
- Nick Cassimatis <nick@psych.stanford.edu> wrote:
- >I'm having trouble getting default constructors to work in another
- >class' constructor: e.g.,
- >
- >class position {
- > int x,y,z;
-
- try adding:
-
- public:
-
- > position() {x = y = z = 0;};
- > position(int, int, int);
- >};
- >
- >What exactly is meant by "access"? And why wouldn't I have it to an
- >object that's already been declared?
- >
- >-Nick
-
- The default access attribute for class members is "private". Without
- adding the "public" section, your contructors are not accessible
- outside the class.
-
- This does not make private or proected constructors uselss. Protected
- constructors are accesible to friends of the class. Also, it is a
- common technique to define and make non-public default, copy, and
- assignment constructors if such operations are not to be permitted.
-
- You may want to read more about these attributes in a C++ book.
-
- Hope this helps.
- Jeff
-
-
-